<template>
	<div class="box">
		<h2>表格</h2>
		<my-table :columns="columns"
				  :tableList="tableList"
				  :loadFlag="loadFlag"
				  :loadError="loadError"/>
	</div>
</template>

<script>
export default {
  name: "Index",
  data() {
    return {
      loadFlag: true,
      loadError: false,
      columns: [
        { field: "xh", title: "序号", width: 60, align: "left" }, //align 默认center
        { field: "slbm", title: "爱好，router-link", to: "500", query: "xh" }, ///500?id=1 通过路由跳转，有局限性
        { field: "fwmc", title: "事项名称，外链", hasLink: "url" }, //加外链
        { field: "zhpf", title: "综合评分" }
      ]
    };
  },
  created: function() {
    this.getTableData();
  },
  methods: {
    getTableData() {
      this.$http.get("api/security/token").then(res => {
        document.cookie = "XSRF-TOKEN=" + res.data + ";path=/;";
        this.loadFlag = true;
        this.loadError = false;
        let params = this.$qs.stringify({
          pageSize: this.limit,
          pageNum: this.currentPage
        });
        this.$http.post("api/analysis/serviceQuality", params).then(
          res => {
            this.loadFlag = false;
            this.totalCount = res.data.total;
            this.tableList = res.data.list;
          },
          () => {
            this.loadError = true;
          }
        );
      });
    }
  }
};
</script>
